package org.chnxi.study.design.single;

import java.lang.reflect.Constructor;

public class HungrySingleTest {

    public static void main(String[] args) throws Exception {

        new Thread(()->{
            try{
                Constructor<HungrySingle> declaredConstructor = HungrySingle.class.getDeclaredConstructor(null);
                declaredConstructor.setAccessible(true);
                HungrySingle hungrySingle = declaredConstructor.newInstance();
                System.out.println(Thread.currentThread().getName() + ";hungrySingle.hashcode="+hungrySingle.hashCode());
            }catch (Exception e){
                e.printStackTrace();
            }
        } , "T-1").start();

        new Thread(()->{
            HungrySingle instance = HungrySingle.getInstance();
            System.out.println(Thread.currentThread().getName()+";instance.hashcode="+instance.hashCode());
        }, "T-2").start();


    }

}
